{% extends "common/layout.html" %}
{% block content %}

    <div class="row bg-primary">
        <div class="col-sm-10 col-sm-offset-1">
            <h2>移动办公平台数据管理系统</h2>
            <h6>Mobile office platform data management system</h6>
        </div>
    </div>

    <div class="row" style="margin-top: 20px">

        <div class="col-sm-10 col-sm-offset-1">


            <table class="table table-bordered table-hover">
                <tr>
                    <th class="info">id</th>
                    <th class="info">时间</th>
                    <th class="info">餐类</th>
                    <th class="info">种类</th>
                    <th class="info">内容</th>
                    <th class="info">城市</th>
                    <th class="info">功能</th>
                </tr>
                {% for item in eating %}
                    <tr>
                        <th>{{ item.id }}</th>
                        <th>{{ item.time }}</th>
                        <th>{{ item.classone }}</th>
                        <th>{{ item.classtwo }}</th>
                        <th>{{ item.content }}</th>
                        <th>{{ item.city }}</th>
                        <th>
                            <button type="button" class="btn btn-primary" data-toggle="modal"
                                    data-target="#updateModal" data-id="{{ item.id }}"
                                    data-time="{{ item.time }}" data-classone="{{ item.classone }}"
                                    data-classtwo="{{ item.classtwo }}" data-content="{{ item.content }}"
                                    data-city="{{ item.city }}">编辑
                            </button>
                            <a class="btn btn-danger" style="margin-left: 20px"
                               href="{{ buildUrl('/eating/admindelete') }}?id={{ item.id }}">删除</a>
                        </th>
                    </tr>

                {% endfor %}
            </table>
            <button type="button" class="btn btn-success" data-toggle="modal"
                    data-target="#addModal"
                    data-city="太原">新增一天模版
            </button>
        </div>
    </div>

    <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">修改菜单</h4>
                </div>
                <div class="modal-body">

                    <form class="form" style="margin-top: 10px" method="post"
                          action="{{ buildUrl('/eating/adminadd') }}">

                        <div class="form-group">
                            <label class="control-label">时间:</label>
                            <input type="text" class="form-control" id="time1" name="time1">
                        </div>


                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button class="btn btn-primary" type="submit" value="Submit">新增模版</button>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>



    {#    修改模态框#}
    <div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">修改菜单</h4>
                </div>
                <div class="modal-body">

                    <form class="form" style="margin-top: 10px" method="post"
                          action="{{ buildUrl('/eating/adminupdate') }}">

                        <div class="form-group">
                            <label class="control-label">ID:</label>
                            <input type="text" class="form-control" id="id" name="id">
                        </div>

                        <div class="form-group">
                            <label class="control-label">时间:</label>
                            <input type="text" class="form-control" id="time" name="time">
                        </div>

                        <div class="form-group">
                            <label for="recipient-name" class="control-label">餐类:</label>
                            <input type="text" class="form-control" id="classone" name="classone">
                        </div>

                        <div class="form-group">
                            <label for="recipient-name" class="control-label">种类:</label>
                            <input type="text" class="form-control" id="classtwo" name="classtwo">
                        </div>

                        <div class="form-group">
                            <label for="recipient-name" class="control-label">内容:</label>
                            <input type="text" class="form-control" id="content" name="content">
                        </div>

                        <div class="form-group">
                            <label for="message-text" class="control-label">城市:</label>
                            <textarea class="form-control" id="city" name="city"></textarea>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button class="btn btn-primary" type="submit" value="Submit">修改信息</button>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>


    <script>
        $('#updateModal').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget); // Button that triggered the modal
            var id = button.data('id');
            var time = button.data('time');
            var classone = button.data('classone');
            var classtwo = button.data('classtwo');
            var content = button.data('content');
            var city = button.data('city');

            var modal = $(this);
            {#modal.find('.modal-title').text('New message to ' + recipient);#}
            {#modal.find('.modal-body input').val(recipient)#}
            {#modal.find('.modal-body textarea').val(recipient)#}
            document.getElementById("id").value = id;
            document.getElementById("time").value = time;
            document.getElementById("classone").value = classone;
            document.getElementById("classtwo").value = classtwo;
            document.getElementById("content").value = content;
            document.getElementById("city").value = city;
        });

    </script>



{% endblock %}


